﻿using System;
using System.Collections.Generic;
using System.Text;
using OneMG.Phoenix.Service.Contracts;
using OneMG.Phoenix.Service.Model;
using OneMG.Phoenix.IBatisRepository;
using OneMG.Phoenix.Respository;
using System.Data;
using OneMG.Phoenix.Entity;

namespace OneMG.Phoenix.Service
{
    public class AdminGroupService : IAdminGroupService
    {
		 IAdminGroup adminGroup = new AdminGroupRepository();
		 
        public System.Int32 AddAdminGroup(AdminGroupModel model)
        {
			EAdminGroup entity = ConvertModelToEntity(model);
			
            return adminGroup.AddAdminGroup(entity);
        }

		public void UpdateByGroupID (AdminGroupModel model)
		{
			EAdminGroup entity = ConvertModelToEntity(model);

            adminGroup.UpdateByGroupID(entity);

		}

		public void DeleteByGroupID (System.Int32 groupID)
		{
		
            adminGroup.DeleteByGroupID(groupID);

		}
		 
        public AdminGroupModel GetByGroupID (System.Int32 groupID)
        {
        
			EAdminGroup entity = adminGroup.GetByGroupID(groupID);
			
            AdminGroupModel model = ConvertEntityToModel(entity);


            return model;
        }
        
		public AdminGroupModel ConvertEntityToModel(EAdminGroup entity)
		{
			if (entity == null)
            {
                return null;
            }
			AdminGroupModel model = new AdminGroupModel();
                        model.GroupID = entity.GroupID;
                        model.GroupName = entity.GroupName;
                        model.Memo = entity.Memo;
                        model.OrgID = entity.OrgID;
                        return model;
		}
		
		public EAdminGroup ConvertModelToEntity(AdminGroupModel model)
		{
			if (model == null)
            {
                return null;
            }
			EAdminGroup entity = new EAdminGroup();
                        entity.GroupID = model.GroupID;
                        entity.GroupName = model.GroupName;
                        entity.Memo = model.Memo;
                        entity.OrgID = model.OrgID;
                        return entity;
		}
    }
}